﻿cmake_minimum_required(VERSION 3.8)

#项目名
SET(PROJECT_NAME MFCApplication)
project(${PROJECT_NAME})

# define output path
SET(PROJECT_DIR ".")
SET(CMAKE_INSTALL_PREFIX ${PROJECT_DIR})
SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_INSTALL_PREFIX})
SET(LIBRARY_OUTPUT_PATH ${CMAKE_INSTALL_PREFIX})

#UNICODE字符集
add_definitions(-DUNICODE -D_UNICODE)

#共享DLL中使用 MFC
add_definitions(-D_AFXDLL)

#设置预编译项
# add_definitions( -DQLEMR_CFG_DLL )

# 1 在静态库中使用MFC,2共享方式使用mfc
set(CMAKE_MFC_FLAG 2)
# set(CMAKE_CXX_FLAGS_RELEASE "/MT")
# set(CMAKE_CXX_FLAGS_DEBUG "/MTd")

# add link lib
#link_libraries(winmm.lib)

FILE(GLOB SRC_FILES ${PROJECT_DIR}/*.cpp)
FILE(GLOB HEAD_FILES ${PROJECT_DIR}/*.h)
FILE(GLOB RC_FILES ${PROJECT_DIR}/*.rc ${PROJECT_DIR}/*.def)

# add_library(${PROJECT_NAME} SHARED ${SRC_FILES} ${HEAD_FILES} ${RC_FILES})
add_executable(${PROJECT_NAME} ${SRC_FILES} ${HEAD_FILES} ${RC_FILES})

if (CMAKE_SYSTEM_NAME MATCHES "Windows")
    # 预编译头文件和源文件的路径
    set(STDAFX_PCH_H ${PROJECT_DIR}/stdafx.h)
    set(STDAFX_PCH_C ${PROJECT_DIR}/stdafx.cpp)

    # 此处是关键，添加我们在msvcpch.cmake定义的宏
    USE_MSVC_PCH(${PROJECT_NAME} ${STDAFX_PCH_H} ${STDAFX_PCH_C})
endif ()

#子系统窗口 
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS")
